package com.airlines.crewassignment.service.crew.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.airlines.base.service.base.impl.BaseServiceImpl;
import com.airlines.common.Page;
import com.airlines.crewassignment.dao.CrewMapper;
import com.airlines.crewassignment.domain.Crew;
import com.airlines.crewassignment.service.crew.CrewManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xxxx
 * @date 2018/7/27
 * @company xxxx Airlines
 * @description 管理干部维护
 */
@Service
public class CrewManagementServiceImpl  implements CrewManagementService {
    @Autowired
    private CrewMapper crewMapper;


    @Override
    public Page getCrewList(Crew crew, Page page) {
        PageHelper.startPage(page.getPageNumber(), page.getPageSize());
        List<Crew> list = crewMapper.getCrewList(crew);
        PageInfo<Crew> pageInfo = new PageInfo<Crew>(list);
        page.setTotal(String.valueOf(pageInfo.getTotal()));
        page.setRows(pageInfo.getList());
        return page;
    }

    @Override
    public Crew getCrewByWorkcode(String workcode) {
        return crewMapper.getCrewByWorkcode(workcode);
    }

    @Override
    public Integer updateManagerByWorkcode(Crew crew) {
        return crewMapper.updateManagerByWorkcode(crew);
    }


}
